<?php
include_once("common.inc.php");

$query = "INSERT INTO avatars (Key, Name, ObjectKey, ObjectName, Location, Pos, Rot, Vel, LastUpdate) VALUES ('" .
	$_REQUEST['avatarKey'] . "','" .
	$_REQUEST['avatarName'] . "','" .
	addslashes($_SERVER['HTTP_X_SECONDLIFE_OBJECT_KEY']) . "','" .
	addslashes($_SERVER['HTTP_X_SECONDLIFE_OBJECT_NAME']) . "','" .
	addslashes($_SERVER['HTTP_X_SECONDLIFE_REGION']) . "','" .
	$_REQUEST['avatarPos'] . "','" .
	$_REQUEST['avatarRot'] . "','" .
	$_REQUEST['avatarVel'] . "'," .
	 " datetime('now'))";
	  
if ($db->query($query, SQLITE_BOTH, $error_msg) === FALSE)
{
	header("HTTP/1.0 503 Service Unavailable");
	printf("INSERT query '". $query . "' failed: %s\n", $error_msg);
	exit();
}
header("HTTP/1.0 200 OK");
header("Content-type: text/plain; charset=utf-8");
// var_dump($_REQUEST);
echo "'" . $_REQUEST['avatarName'] . "' tracked!";
?>